﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sublimation
{
    public class SlotTechnology : Slot
    {
        #region attributes
        #endregion


        public SlotTechnology(WorldProperties worldProperties, SlotKind kind, Tower ownerTower)
            : base(worldProperties, kind, ownerTower,false)
        {
        }

        public override void build()
        {
            base.build();
            switch (kind)
            {
                case SlotKind.General_up:
                    ownerTower.Shield.MaxShieldEnergy += damage * 700;
                    ownerTower.Shield.ShieldPerSecond += damage * 70;
                    ownerTower.RangedFactor += damage;
                    ownerTower.RateFactor += damage;
                    ownerTower.DamageFactor += damage;
                    ownerTower.Energy.EnergyPerSecond += damage * 100;
                    break;
                case SlotKind.Sheild:
                    ownerTower.Shield.MaxShieldEnergy += damage * 2000;
                    ownerTower.Shield.ShieldPerSecond += damage * 190;
                    ownerTower.RangedFactor += damage;
                    ownerTower.RateFactor += damage;
                    ownerTower.DamageFactor += damage;
                    ownerTower.Energy.EnergyPerSecond += damage * 100;
                    break;
                case SlotKind.Energy_up:
                    ownerTower.Shield.MaxShieldEnergy += damage * 700;
                    ownerTower.Shield.ShieldPerSecond += damage * 70;
                    ownerTower.RangedFactor += damage;
                    ownerTower.RateFactor += damage;
                    ownerTower.DamageFactor += damage;
                    ownerTower.Energy.EnergyPerSecond += damage * 500;
                    break;
                case SlotKind.Weapon_up:
                    ownerTower.Shield.MaxShieldEnergy += damage * 700;
                    ownerTower.Shield.ShieldPerSecond += damage * 70;
                    ownerTower.RangedFactor += damage * 3;
                    ownerTower.RateFactor += damage * 3;
                    ownerTower.DamageFactor += damage * 3;
                    ownerTower.Energy.EnergyPerSecond += damage * 100;
                    break;
            }
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            Rotation = ownerTower.Rotation + Orientation;
        }

        public override void Kill()
        {
            base.Kill();
            if (!Building)
            {
                switch (kind)
                {
                    case SlotKind.General_up:
                        ownerTower.Shield.MaxShieldEnergy -= damage * 700;
                        ownerTower.Shield.ShieldPerSecond -= damage * 70;
                        ownerTower.RangedFactor -= damage;
                        ownerTower.RateFactor -= damage;
                        ownerTower.DamageFactor -= damage;
                        ownerTower.Energy.EnergyPerSecond -= damage * 100;
                        break;
                    case SlotKind.Sheild:
                        ownerTower.Shield.MaxShieldEnergy -= damage * 2000;
                        ownerTower.Shield.ShieldPerSecond -= damage * 190;
                        ownerTower.RangedFactor -= damage;
                        ownerTower.RateFactor -= damage;
                        ownerTower.DamageFactor -= damage;
                        ownerTower.Energy.EnergyPerSecond -= damage * 100;
                        break;
                    case SlotKind.Energy_up:
                        ownerTower.Shield.MaxShieldEnergy -= damage * 700;
                        ownerTower.Shield.ShieldPerSecond -= damage * 70;
                        ownerTower.RangedFactor -= damage;
                        ownerTower.RateFactor -= damage;
                        ownerTower.DamageFactor -= damage;
                        ownerTower.Energy.EnergyPerSecond -= damage * 500;
                        break;
                    case SlotKind.Weapon_up:
                        ownerTower.Shield.MaxShieldEnergy -= damage * 700;
                        ownerTower.Shield.ShieldPerSecond -= damage * 70;
                        ownerTower.RangedFactor -= damage * 3;
                        ownerTower.RateFactor -= damage * 3;
                        ownerTower.DamageFactor -= damage * 3;
                        ownerTower.Energy.EnergyPerSecond -= damage * 100;
                        break;
                }
            }
        }
        protected override void LoadContent()
        {
            base.LoadContent();
            Sprite = Game.Content.Load<Texture2D>("Sprites/tech");
        }
    }
}
